// 时间格式化函数
export function formatTime(timestamp, format = '{y}-{m}-{d} {h}:{i}') {
  const date = new Date(timestamp)
  const formatObj = {
    y: date.getFullYear(),
    m: date.getMonth() + 1,
    d: date.getDate(),
    h: date.getHours(),
    i: date.getMinutes(),
    s: date.getSeconds()
  }
  return format.replace(/{([ymdhis])\}+/g, (result, key) => {
    const value = formatObj[key]
    return value.toString().padStart(2, '0')
  })
}
